package com.cskaoyan.controller.admin;

import com.cskaoyan.bean.bo.ConfigExpressBO;
import com.cskaoyan.bean.bo.ConfigMallBO;
import com.cskaoyan.bean.bo.ConfigOrderBO;
import com.cskaoyan.bean.bo.ConfigWxBO;
import com.cskaoyan.bean.vo.*;
import com.cskaoyan.service.ConfigService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: zoey-zhu
 * @description:  配置管理: admin/config ---》 查询system表
 * @Date 14:40 2021/7/9
 */
@RestController
@RequestMapping("admin/config")
public class ConfigController {

    @Autowired
    ConfigService configService;

    /**
     * @Author: zoey-zhu
     * @description: 商场配置：查询system表
     * @Date 14:40 2021/7/9
     * url: http://182.92.235.201:8083/admin/config/mall
     */
    @GetMapping("/mall")
    @RequiresPermissions("admin:config:mall:list")
    public BaseRespVo configMall() {

        ConfigMallVO data = configService.configMall();
        return BaseRespVo.ok(data);
    }

    /**
     * @Author: zoey-zhu
     * @description: 商场配置：更新system表
     * @Date 19:59 2021/7/12
     * url: http://182.92.235.201:8083/admin/config/mall
     */
    @PostMapping("/mall")
    public BaseRespVo configMallUpdate(@RequestBody ConfigMallBO configMallBO) {

        int update = configService.configMallUpdate(configMallBO);
        return BaseRespVo.ok();
    }

    /**
     * @Author: zoey-zhu
     * @description: 运费配置：查询system表
     * @Date 15:07 2021/7/9
     * url: http://182.92.235.201:8083/admin/config/express
     */
    @GetMapping("/express")
    @RequiresPermissions("admin:config:express:list")
    public BaseRespVo configExpress() {

        ConfigExpressVO data = configService.configExpress();
        return BaseRespVo.ok(data);
    }

    /**
     * @Author: zoey-zhu
     * @description: 运费配置：更新system表
     * @Date 20:02 2021/7/12
     * url: http://182.92.235.201:8083/admin/config/express
     */
    @PostMapping("/express")
    public BaseRespVo configExpressUpdate(@RequestBody ConfigExpressBO configExpressBO) {

        int update = configService.configExpressUpdate(configExpressBO);
        return BaseRespVo.ok();
    }


    /**
     * @Author: zoey-zhu
     * @description: 订单配置：查询system表
     * @Date 15:07 2021/7/9
     * url: http://182.92.235.201:8083/admin/config/order
     */
    @GetMapping("/order")
    @RequiresPermissions("admin:config:order:list")
    public BaseRespVo configOrder() {

        ConfigOrderVO data = configService.configOrder();
        return BaseRespVo.ok(data);
    }

    /**
     * @Author: zoey-zhu
     * @description: 订单配置：更新system表
     * @Date 20:02 2021/7/12
     * url: http://182.92.235.201:8083/admin/config/order
     */
    @PostMapping("/order")
    public BaseRespVo configOrderUpdate(@RequestBody ConfigOrderBO configOrderBO) {

        int update = configService.configOrderUpdate(configOrderBO);
        return BaseRespVo.ok();
    }


    /**
     * @Author: zoey-zhu
     * @description: 小程序配置：查询system表
     * @Date 15:07 2021/7/9
     * url: http://182.92.235.201:8083/admin/config/wx
     */
    @GetMapping("/wx")
    @RequiresPermissions("admin:config:wx:list")
    public BaseRespVo configWx() {

        ConfigWxVO data = configService.configWx();
        return BaseRespVo.ok(data);
    }

    /**
     * @Author: zoey-zhu
     * @description: 小程序配置：更新system表
     * @Date 20:02 2021/7/12
     * url: http://182.92.235.201:8083/admin/config/wx
     */
    @PostMapping("/wx")
    public BaseRespVo configWxUpdate(@RequestBody ConfigWxBO configWxBO) {

        int update = configService.configWxUpdate(configWxBO);
        return BaseRespVo.ok();
    }
}
